﻿<phone:PhoneApplicationPage x:Class="LiveEduWizard.Views.AppointmentView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
    xmlns:local="clr-namespace:LiveEduWizard"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    d:DataContext="{d:DesignData ../SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <phone:PhoneApplicationPage.Resources>
        <local:VisibilityConverter x:Key="visibilityConverter"/>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Visibility="{Binding}" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="APPOINTMENT" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="details" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" DataContext="{Binding ActiveAppointment}">
            <StackPanel>
                <TextBlock TextWrapping="Wrap" Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}" Visibility="{Binding Path=Title.Length, Converter={StaticResource visibilityConverter}}"/>
                <TextBlock TextWrapping="Wrap" Text="{Binding Subject}" Style="{StaticResource PhoneTextNormalStyle}" Visibility="{Binding Path=Subject.Length, Converter={StaticResource visibilityConverter}}"/>
                <TextBlock TextWrapping="Wrap" Text="{Binding DetailDateTime}" Style="{StaticResource PhoneTextNormalStyle}" />
                <TextBlock TextWrapping="Wrap" Text="{Binding Location}" Style="{StaticResource PhoneTextNormalStyle}" Visibility="{Binding Path=Location.Length, Converter={StaticResource visibilityConverter}}"/>
                <TextBlock TextWrapping="Wrap" Text="{Binding Details}" Grid.Row="0" Style="{StaticResource PhoneTextNormalStyle}" Margin="12" Visibility="{Binding Path=Details.Length, Converter={StaticResource visibilityConverter}}" />
                <Grid x:Name="ItemsPanel">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    
                    <TextBlock Text="Related:" Grid.Row="0" Grid.Column="0" Style="{StaticResource PhoneTextSubtleStyle}" Visibility="{Binding Path=Related.Count, Converter={StaticResource visibilityConverter}}" />
                    <ListBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Related}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Tap="Related_Tap">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Grid.Column="0" Style="{StaticResource PhoneTextNormalStyle}"/>
                                    <Image Grid.Column="1"/>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <TextBlock Text="Organiser:" Grid.Row="1" Grid.Column="0" Style="{StaticResource PhoneTextSubtleStyle}" Visibility="{Binding Path=Organizer, Converter={StaticResource visibilityConverter}}" />
                    <TextBlock TextWrapping="Wrap" Text="{Binding Path=Organizer.DisplayName}" Grid.Row="1" Grid.Column="1" Style="{StaticResource PhoneTextNormalStyle}" Visibility="{Binding Path=Organizer, Converter={StaticResource visibilityConverter}}"/>

                    <TextBlock Text="Attendees:" Grid.Row="2" Grid.Column="0" Style="{StaticResource PhoneTextSubtleStyle}" Visibility="{Binding Path=Attendees.Count, Converter={StaticResource visibilityConverter}}" />
                    <ListBox Grid.Row="2" Grid.Column="3" ItemsSource="{Binding Attendees}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <TextBlock Text="{Binding DisplayName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </StackPanel>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>